package longrise.phone.com.bjjt_jyb.compensate;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.TimePickerView;
import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.ILFMsgListener;
import com.longrise.android.LFView;
import com.longrise.android.loaddata.newloaddata.LoadDataManagerCar;
import com.longrise.android.loaddata.newloaddata.LoadDataManagerFather;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import longrise.phone.com.bjjt_jyb.Activity.MainActivity;
import longrise.phone.com.bjjt_jyb.Application.BaseApplication;
import longrise.phone.com.bjjt_jyb.Constant.URLConstant;
import longrise.phone.com.bjjt_jyb.R;
import longrise.phone.com.bjjt_jyb.Utils.ApiImpI;
import longrise.phone.com.bjjt_jyb.Utils.CommontUtils;
import longrise.phone.com.bjjt_jyb.Utils.DialogUtils;
import longrise.phone.com.bjjt_jyb.Utils.StringUtils;
import longrise.phone.com.bjjt_jyb.Utils.UiUtil;
import longrise.phone.com.bjjt_jyb.Utils.UiUtils;


/**
 * 生成协议书，Created by Administrator on 2016/5/12.
 */

public class CreateAgreementViewYF extends LFView implements View.OnClickListener, MainActivity.OnActivityReturnBitmap, ILFMsgListener {
    private Context context = null;
    private View view = null;
    private Button bt_createappointmen1;
    private Dialog processDialog;
    private BaseApplication mApplication;
    private Button bt_createappointmen2;
    private EditText tv_createagreement6;
    private TextView tv_createagreement7;
    private EditText tv_createagreement8;
    private TextView tv_createappointment2;
    private EntityBean[] CreateAgreementbean;
    private String appCaseno;
    private String et_createagreement1;
    private EditText et_createagreement2;
    private String dutytype2;
    // 本方请求签名
    private static final int SIDE_REQUEST_CODE = 0x0011;
    private String dutytype1;
    private LinearLayout hn_btn_back;
    private ImageView iv_createagreement_me;
    private ImageView iv_deletesign_me;
    private Bitmap bitmap;
    private Bitmap otherBitmap;
    private Bitmap ownBitmap;
    private String carownname2;
    private String carownphone2;
    private String casecarno2;
    private Button bt_sign_yf;
    private RelativeLayout rl_sign_yf;
    private RadioGroup rg_ifnosure1yf;
    private Boolean jfrefuse;
    private TimeCount time;
    private Integer fromwhere;
    private String kckpUserType;
    private String url;
    private String myName;
    private String myphone;
    private EditText tv_place;
    private String tv_placeCon;
    private boolean refuse = false;//标识是否拒签。默认不拒签
    private TextView tv_place_x;
    private TextView tv_getplace;
    private TextView tv_accidentTime;
    private LinearLayout ll_time;
    private String casehaptime;

    public CreateAgreementViewYF(Context c, EntityBean[] beans, String appCaseno, Bitmap otherBitmap, String et_createagreement1, Boolean jfrefuse, Integer fromwhere) {
        super(c);
        this.context = c;
        this.mApplication = (BaseApplication) c.getApplicationContext();
        this.CreateAgreementbean = beans;
        this.appCaseno = appCaseno;
        if (context instanceof MainActivity) {
            ((MainActivity) context).setOnActivityReturnBitmap(this);
        }
        this.otherBitmap = otherBitmap;
        this.et_createagreement1 = et_createagreement1;
        this.jfrefuse = jfrefuse;
        this.fromwhere = fromwhere;
    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
        queryAddress();
    }

    private void initView() {
        view = View.inflate(context, R.layout.view_createagreementviewyf, null);
        bt_createappointmen1 = (Button) view.findViewById(R.id.bt_createappointmen1);
        bt_createappointmen2 = (Button) view.findViewById(R.id.bt_createappointmen2);
        bt_sign_yf = (Button) view.findViewById(R.id.bt_sign_yf);
        rg_ifnosure1yf = (RadioGroup) view.findViewById(R.id.rg_ifnosure1yf);
        RadioButton rb_ifnosure_2yf = (RadioButton) view.findViewById(R.id.rb_ifnosure_2yf);
        rb_ifnosure_2yf.setChecked(true);
        rl_sign_yf = (RelativeLayout) view.findViewById(R.id.rl_sign_yf);
        tv_createappointment2 = (TextView) view.findViewById(R.id.tv_createappointment2);
        //本方数据
        TextView tv_createagreement5 = (TextView) view.findViewById(R.id.tv_createagreement5);
        TextView tv_new5 = (TextView) view.findViewById(R.id.tv_new5);
        tv_createagreement6 = (EditText) view.findViewById(R.id.tv_createagreement6);
        tv_createagreement7 = (TextView) view.findViewById(R.id.tv_createagreement7);
        tv_createagreement8 = (EditText) view.findViewById(R.id.tv_createagreement8);
        tv_accidentTime = (TextView) view.findViewById(R.id.tv_accidentTime);
        iv_createagreement_me = (ImageView) view.findViewById(R.id.iv_createagreement_me);//本方驾驶员签名图片
        iv_deletesign_me = (ImageView) view.findViewById(R.id.iv_deletesign_me);//本方驾驶员签名图片删除
        et_createagreement2 = (EditText) view.findViewById(R.id.et_createagreement2);
        tv_place = (EditText) view.findViewById(R.id.tv_place);
        tv_place_x = (TextView) view.findViewById(R.id.tv_place_x);
        ll_time = (LinearLayout) view.findViewById(R.id.ll_time);
        ll_time.setOnClickListener(this);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        //协警获取最新地址
        tv_getplace = (TextView) view.findViewById(R.id.tv_getplace);
        View v_getplace = (View) view.findViewById(R.id.v_getplace);
        kckpUserType = mApplication.getKckpUserType();
        tv_title.setText("生成认定书");
        bt_createappointmen1.setText("提交并生成认定书");
        if (null != kckpUserType && "9".equals(kckpUserType)) {
            bt_createappointmen2.setVisibility(View.GONE);//交警处理的案件，不能不认可
            tv_place_x.setVisibility(View.GONE);
            tv_place.setVisibility(View.VISIBLE);
            tv_getplace.setVisibility(View.GONE);
            v_getplace.setVisibility(View.GONE);
        } else {
            bt_createappointmen2.setVisibility(View.VISIBLE);
            tv_place_x.setVisibility(View.VISIBLE);
            tv_place.setVisibility(View.GONE);
            tv_getplace.setVisibility(View.VISIBLE);
            v_getplace.setVisibility(View.VISIBLE);
        }
        EntityBean otherBean = null;//对方信息
        EntityBean myBean = null;//我的信息
        for (EntityBean element : CreateAgreementbean) {
            String ownother = element.getString("ownother");
            if (TextUtils.equals(ownother, "0")) {
                myBean = element;
            } else if (TextUtils.equals(ownother, "1")) {
                otherBean = element;
            }
        }

        //本方数据
        String carownphone1 = (String) myBean.get("carownphone");
        dutytype1 = (String) myBean.get("dutytype");
        String carownname1 = (String) myBean.get("carownname");
        //String id1 = (String)myBean.get("id");
        String casecarno1 = (String) myBean.get("casecarno");

        //对方数据
        carownphone2 = (String) otherBean.get("carownphone");
        dutytype2 = (String) otherBean.get("dutytype");
        carownname2 = (String) otherBean.get("carownname");
        //String id2 = (String)otherBean.get("id");
        casecarno2 = (String) otherBean.get("casecarno");

        if ("0".equals(dutytype1)) {
            tv_createagreement5.setText("全责");
        }
        if ("1".equals(dutytype1)) {
            tv_createagreement5.setText("无责");
        }
        if ("2".equals(dutytype1)) {
            tv_createagreement5.setText("同责");
        }
        if ("3".equals(dutytype1)) {
            tv_createagreement5.setText("主责");
        }
        if ("4".equals(dutytype1)) {
            tv_createagreement5.setText("次责");
        }
        tv_createagreement6.setText(carownname1);
        tv_createagreement7.setText(casecarno1);
        tv_createagreement8.setText(carownphone1);
        if (fromwhere == 3 || fromwhere == 4 || fromwhere == 11 || fromwhere == 10) {
            tv_new5.setText("车辆品牌");
        }
    }

    private void regEvent(boolean b) {
        if (null != bt_createappointmen1) {
            bt_createappointmen1.setOnClickListener(b ? this : null);
        }
        if (null != bt_createappointmen2) {
            bt_createappointmen2.setOnClickListener(b ? this : null);
        }
        if (null != bt_sign_yf) {
            bt_sign_yf.setOnClickListener(b ? this : null);
        }
        if (null != tv_createappointment2) {
            tv_createappointment2.setOnClickListener(b ? this : null);
        }
        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
        if (null != iv_createagreement_me) {
            iv_createagreement_me.setOnClickListener(b ? this : null);
        }
        if (null != iv_deletesign_me) {
            iv_deletesign_me.setOnClickListener(b ? this : null);
        }
        if (null != tv_getplace) {
            tv_getplace.setOnClickListener(b ? this : null);
        }
        if (null != ll_time) {
            ll_time.setOnClickListener(b ? this : null);
        }
        if (b) {
            this.addILFMsgListener(this);
        } else {
            this.removeILFMsgListener(this);
        }
        if (null != rg_ifnosure1yf) {
            rg_ifnosure1yf.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup radioGroup, int i) {
                    switch (i) {
                        case R.id.rb_ifnosure_1yf:
                            refuse = true;
                            break;
                        case R.id.rb_ifnosure_2yf:
                            refuse = false;
                            break;
                    }
                }
            });

        }
    }

    private class TimeCount extends CountDownTimer {
        private TimeCount(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
        }

        @Override
        public void onFinish() {// 计时完毕
            tv_createappointment2.setText("重发验证码");
            tv_createappointment2.setClickable(true);
            time.cancel();
        }

        @Override
        public void onTick(long millisUntilFinished) {// 计时过程
            tv_createappointment2.setClickable(false);//防止重复点击
            tv_createappointment2.setText(millisUntilFinished / 1000 + "s");
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_createappointmen1:
                myphone = tv_createagreement8.getText().toString().trim();
                myName = tv_createagreement6.getText().toString().trim();
                if(null != kckpUserType && "9".equals(kckpUserType))tv_placeCon = tv_place.getText().toString().trim();
                else tv_placeCon = tv_place_x.getText().toString().trim();
                if (TextUtils.isEmpty(myName)) {
                    UiUtil.showToast(context, "姓名不能为空");
                    return;
                }
                if (!StringUtils.isPhone(myphone)) {
                    UiUtil.showToast(context, "联系电话错误");
                    return;
                }
                if (carownphone2.equals(myphone)) {
                    UiUtil.showToast(context, "事故双方联系电话相同");
                    return;
                }
                if (!refuse) {
                    if (null == ownBitmap) {
                        UiUtil.showToast(context, "请乙方驾驶员签名");
                        return;
                    }
                    /**  去掉验证码只签名 **/
                   /* if (TextUtils.isEmpty(et_createagreement2.getText().toString().trim())) {
                        UiUtil.showToast(context, "请填写乙方验证码");
                        return;
                    }*/
                }
                if ((null != kckpUserType && "9".equals(kckpUserType))) {
                    //交警判断地点为空
                    if (StringUtils.isEmpty(tv_placeCon)) {
                        UiUtil.showToast(context, "请填写事故地点");
                        return;
                    }
                }
                try {
                    if(StringUtils.date(CommontUtils.getNowTime(),tv_accidentTime.getText().toString())){
                        UiUtil.showToast(context, "事故时间不得晚于当前时间");
                        return;
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                submitCreateArg();//生成事故责任认定
                break;
            case R.id.bt_createappointmen2:
                //报警
                Intent intent = new Intent(Intent.ACTION_DIAL, Uri
                        .parse("tel:110"));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getContext().startActivity(intent);
                break;
            case R.id.tv_createappointment2:
                String myPhone = tv_createagreement8.getText().toString().trim();
                if (!refuse) {
                    getCode(myPhone);//乙方获取验证码
                    tv_createappointment2.setText("重发验证码");
                } else {
                    UiUtil.showToast(getContext(), "拒绝责任认定无须填写验证码");
                }
                break;
            case R.id.bt_sign_yf:
                if (!refuse) {
                    // 本方签名
                    Intent intent1 = new Intent(context, SignatureActivity.class);
                    if (context instanceof MainActivity) {
                        ((MainActivity) context).startActivityForResult(intent1,
                                SIDE_REQUEST_CODE);
                    }
                } else {
                    UiUtil.showToast(getContext(), "拒绝责任认定无须签字确认");
                }
                break;
            case R.id.iv_deletesign_me:
                bt_sign_yf.setVisibility(View.VISIBLE);//button显示
                rl_sign_yf.setVisibility(View.GONE);
                break;
            case R.id.tv_getplace:
                queryAddress();
                break;
            case R.id.hn_btn_back:
                showHomeView();
                break;
            case R.id.ll_time:
                showTimePiker();
                break;
        }
    }

    private void showTimePiker() {
        boolean[] type = new boolean[]{true, true, true, true, true, false};//显示类型 默认全部显示
        TimePickerView pvTime = new TimePickerView.Builder(context, new TimePickerView.OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {//选中事件回调
                tv_accidentTime.setText(getTime(date));
            }
        }).setType(type)
                .build();
        pvTime.setDate(Calendar.getInstance());//注：根据需求来决定是否使用该方法（一般是精确到秒的情况），此项可以在弹出选择器的时候重新设置当前时间，避免在初始化之后由于时间已经设定，导致选中时间与当前时间不匹配的问题。
        pvTime.show();
    }

    private String getTime(Date date) {//可根据需要自行截取数据显示
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(date);
    }

    /**
     * 提示是否不继续处理，返回首页
     */
    private void showHomeView() {
        UiUtils.showDialog(context, null, null, "是否放弃输入，结束本次快处并返回首页", "返回", "确认",
                new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        closeAllForm();
                        OnDestroy();
                        HomePageView homepageview = new HomePageView(context);
                        FrameworkManager.getInstance().showNewForm(context, homepageview);
                    }
                });
    }

    //提交生成协议书
    private void submitCreateArg() {
        //String recordPath1 = recordManager.getRecordPath();
        processDialog = UiUtil.showProcessDialog(context, "加载数据中...");
        EntityBean bean = new EntityBean();
        EntityBean[] casecarlist;//车主信息数组
        bean.set("appcaseno", appCaseno);
        if (jfrefuse) {
            bean.set("othersig", "");//标识甲方拒签
        } else {
            bean.set("othersig", CommontUtils.Bitmap2Bytes(otherBitmap));//甲方签名
        }
        if (refuse) {
            bean.set("ownsig", "");//标识乙方拒签
        } else {
            bean.set("ownsig", CommontUtils.Bitmap2Bytes(ownBitmap));//乙方签名
        }
        EntityBean bean1 = new EntityBean();
        bean1.set("appcaseno", appCaseno);
        bean1.set("appphone", myphone);
        bean1.set("casehaptime", tv_accidentTime.getText().toString().trim());
        bean1.set("accidentplace", tv_placeCon);
        bean.set("kcbean", bean1);//案件信息，EntityBean
        EntityBean bfBean = new EntityBean();// 本方数据
        bfBean.set("carownname", myName);
        bfBean.set("carownphone", myphone); //手机号
        bfBean.set("casecarno", tv_createagreement7.getText().toString().trim()); // 案件车牌号
        bfBean.set("dutytype", dutytype1);//责任类型
        if (refuse) {
            bfBean.set("isrefused", "0");//标识乙方拒签
            bfBean.set("code", ""); // 验证码
        } else {
            bfBean.set("isrefused", "1");
            bfBean.set("code", et_createagreement2.getText().toString().trim()); // 验证码
        }
        bfBean.set("party", "0");//标识乙方
        /*if(null==recordPath1){
            bfBean.set("voice", "");//录音文件
        }
        else{
            bfBean.set("voice", CommontUtils.encodeBase64File(recordPath1));//录音文件
        }*/
        EntityBean dfBean = new EntityBean();// 对方数据
        dfBean.set("carownname", carownname2);
        dfBean.set("carownphone", carownphone2); //手机号
        dfBean.set("casecarno", casecarno2); // 案件车牌号
        dfBean.set("dutytype", dutytype2);//责任类型
        if (jfrefuse) {
            dfBean.set("isrefused", "0");//标识甲方拒签
            dfBean.set("code", ""); // 验证码
        } else {
            dfBean.set("isrefused", "1");//标识甲方确认了
            dfBean.set("code", et_createagreement1); // 验证码
        }
        dfBean.set("party", "1");//标识甲方
        /*if(null==recordPath){
            dfBean.set("voice","");//录音文件
        }else {
            dfBean.set("voice", CommontUtils.encodeBase64File(recordPath));//录音文件
        }*/
        casecarlist = new EntityBean[]{bfBean, dfBean};
        bean.set("carbeans", casecarlist);
        bean.set("username", mApplication.getKckpName());
        bean.set("token", mApplication.getToken());
        LoadDataManagerCar.getInstance(context).callService(null,
                mApplication.getServerUrl(), URLConstant.KCKPCREATERESPONIMG, bean, new LoadDataManagerFather.OnRequestCompleteListener() {
                    @Override
                    public void onSuccess(String key, String service, Object result) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                        EntityBean bean = (EntityBean) result;
                        String restate = bean.getString("restate");
                        String redes = bean.getString("redes");
                        if ("1".equals(restate)) {
                            EntityBean dataBean = bean.getBean("data");
                            url = dataBean.getString("url");
                            showNext();
                        } else {
                            showsingle(context, redes);
                        }

                    }

                    @Override
                    public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                        UiUtil.showToast(context, "连接超时，请检查网络后重试。");
                    }

                    @Override
                    public void onFinished(String key, String service) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                    }
                });
    }

    private void showsingle(final Context context, String redes) {
        UiUtils.showSingleDialog(context, R.mipmap.a_32, redes, "确认", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                closeAllForm();
                OnDestroy();
                HomePageView homepageview = new HomePageView(context);
                FrameworkManager.getInstance().showNewForm(context, homepageview);
            }
        });
    }

    /**
     * 获取验证码
     */
    private void getCode(String phonenum) {
        if (!StringUtils.isPhone(phonenum)) {
            Toast.makeText(context, "请输入正确的手机号", Toast.LENGTH_SHORT).show();
            return;
        }
        DialogUtils.showDialog(context);
        ApiImpI.getInstance(mApplication).getAgreementCode(phonenum, "11", new ApiImpI.RequestCallBack() {
            @Override
            public void onError(String error) {
                DialogUtils.closeDialog();
            }

            @Override
            public void onSuccess(Object result) {
                DialogUtils.closeDialog();
                EntityBean bean = (EntityBean) result;
                String redes = bean.getString("redes");
                if (!TextUtils.isEmpty(redes)) {
                    UiUtil.showToast(getContext(), redes);
                    time = new TimeCount(60000, 1000);
                    time.start();// 开始计时
                }
            }
        });
    }

    @Override
    public Object onLFMsg(int i, Object... objects) {
        if (i == -10) {//点击返回按键
            showHomeView();
        }
        return false;
    }

    @SuppressLint("NewApi")
    @Override
    public void activityReturnBitmap(int requestCode, int resultCode,
                                     Intent data) {
        if (resultCode == MainActivity.RESULT_OK) {
            Bundle bundle = data.getExtras();
            String bitmapByte = bundle.getString("bitmap");
            bitmap = BitmapFactory.decodeFile(bitmapByte);
            if (requestCode == SIDE_REQUEST_CODE) {
                // 本方签名完成回调函数
                if (bitmap != null) {
                    //隐藏本方的button，显示签名布局，本方签名bitmap转String
                    bt_sign_yf.setVisibility(View.GONE);
                    rl_sign_yf.setVisibility(View.VISIBLE);
                    iv_createagreement_me.setImageBitmap(bitmap);
                    ownBitmap = bitmap;
                }
            }
        }
    }

    @Override
    public void OnDestroy() {
        super.OnDestroy();
        removeILFMsgListener(this);
        if (null != bitmap) {
            bitmap.recycle();
            bitmap = null;
        }
        if (null != ownBitmap) {
            ownBitmap.recycle();
            ownBitmap = null;
        }
        if (null != otherBitmap) {
            otherBitmap.recycle();
            otherBitmap = null;
        }
        view = null;
    }

    private void showNext() {
        WebViewLoad webviewload = new WebViewLoad(context, appCaseno, kckpUserType, url, 0);
        FrameworkManager.getInstance().showNewForm(context, webviewload);
    }
   /* //弹出提交生成协议书ok的提示
    private void showNext() {
        //弹出照片上传正常的dialog
        UiUtils.showDialog(context, null, null, "处理成功，是否返回首页", "暂不", "确认",
                new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        //回到首页
                        closeAllForm();
                        HomePageView homepageview = new HomePageView(context);
                        FrameworkManager.getInstance().showNewForm(context, homepageview);
                    }
                });
    }*/

    /**
     * 联网查询事故发生地点
     */
    private void queryAddress() {
        BaseApplication application = (BaseApplication) context
                .getApplicationContext();
        String url = application.getServerUrl();
        EntityBean bean = new EntityBean();
        bean.set("userflag", application.getKckpName());//用户名
        bean.set("token", application.getToken());
        bean.set("appcaseno", appCaseno);
        processDialog = UiUtil.showProcessDialog(context, "查询数据中...");
        LoadDataManagerCar.getInstance(context).callService(null, url,
                URLConstant.JJAPPGETPLACE, bean, new LoadDataManagerFather.OnRequestCompleteListener() {
                    @Override
                    public void onSuccess(String key, String service, Object result) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                        EntityBean bean = (EntityBean) result;
                        String restate = bean.getString("restate");
                        String redes = bean.getString("redes");
                        String data = bean.getString("data");
                        casehaptime = bean.getString("casehaptime");
                        if ("1".equals(restate)) {
                            tv_accidentTime.setText(casehaptime);
                            if (null != kckpUserType && "9".equals(kckpUserType))
                                tv_place.setText(data);
                            else tv_place_x.setText(data);
                        } else {
                            UiUtil.showToast(context, redes);
                        }
                    }

                    @Override
                    public void onError(String key, String service, LoadDataManagerFather.ResultType resultType) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                        if (resultType == LoadDataManagerFather.ResultType.Failure) {
                            UiUtil.showToast(getContext(), "网络服务故障，请稍后重试");
                        }
                    }

                    @Override
                    public void onFinished(String key, String service) {
                        if (null != processDialog) {
                            if (processDialog.isShowing()) {
                                processDialog.dismiss();
                            }
                        }
                    }
                });
    }
}
